package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.PersonMessage;
import cn.wolfcode.trip.base.domain.SystemMessage;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.PersonMessageMapper;
import cn.wolfcode.trip.base.mapper.SystemMessageMapper;
import cn.wolfcode.trip.base.query.PersonMessageQuery;
import cn.wolfcode.trip.base.service.IPersonMessageService;
import cn.wolfcode.trip.base.service.ISystemMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PersonMessageServiceImpl implements IPersonMessageService {
    @Autowired
    private PersonMessageMapper personMessageMapper;

    @Override
    public void insert(Long sourceId, Long targetId, String content) {
        PersonMessage personMessage = new PersonMessage();
        personMessage.setContent(content);
        User user = new User();
        user.setId(sourceId);
        personMessage.setSourceUser(user);
        user.setId(targetId);
        personMessage.setTargetUser(user);
        personMessage.setTime(new Date());
        personMessageMapper.insert(personMessage);
    }

    @Override
    public List<PersonMessage> selectAll(int state) {
        return null;
    }

    @Override
    public void delete(Long targetUserId) {

    }

    @Override
    public void changeState(int state, Long targetId) {
        personMessageMapper.changeState(state, targetId);
    }

    @Override
    public List<PersonMessage> queryLsit(Long targetId, int state) {
        return personMessageMapper.queryLsit(targetId, state);
    }

}
